-
Notifications
You must be signed in to change notification settings - Fork 441
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
[CI Visibility] Add support for CI Visibility mode in ddtrace #2739
[CI Visibility] Add support for CI Visibility mode in ddtrace #2739
Conversation
BenchmarksBenchmark execution time: 2024-07-05 10:34:05 Comparing candidate commit 93cfbc8 in PR branch Found 1 performance improvements and 0 performance regressions! Performance is the same for 43 metrics, 0 unstable metrics. scenario:BenchmarkHttpServeTrace-24
|
615ef86
to
ccc1a39
Compare
47ea235
to
5862d18
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some comments of things I saw on a first cursory review. I'll be OOO, so maybe @dianashevchenko can take another look.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had to review it at last hour before going OOO, so consider this approval just a way to unlock it :) I'd appreciate if more eyes can take a deeper look cc @dianashevchenko
c7de335
to
e3400dd
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remaining comments which cannot be posted as a review comment to avoid GitHub Rate Limit
golangci
ddtrace/tracer/civisibility_tslv.go|303 col 59| undefined: constants.TestSuiteIDTagName
ddtrace/tracer/civisibility_tslv.go|323 col 61| undefined: constants.TestSessionIDTagName
ddtrace/tracer/civisibility_tslv.go|323 col 61| too many errors) (typecheck)
ddtrace/tracer/civisibility_transport.go|72 col 49| undefined: constants.CiVisibilityAgentlessEnabledEnvironmentVariable
ddtrace/tracer/civisibility_transport.go|87 col 31| undefined: constants.CiVisibilityAgentlessURLEnvironmentVariable
ddtrace/tracer/civisibility_tslv.go|276 col 61| undefined: constants.TestSessionIDTagName
ddtrace/tracer/civisibility_tslv.go|277 col 60| undefined: constants.TestModuleIDTagName
ddtrace/tracer/civisibility_tslv.go|278 col 59| undefined: constants.TestSuiteIDTagName
ddtrace/tracer/civisibility_tslv.go|279 col 57| undefined: constants.ItrCorrelationIDTagName
ddtrace/tracer/civisibility_tslv.go|301 col 61| undefined: constants.TestSessionIDTagName
ddtrace/tracer/civisibility_tslv.go|302 col 60| undefined: constants.TestModuleIDTagName
ddtrace/tracer/civisibility_tslv.go|303 col 59| undefined: constants.TestSuiteIDTagName
ddtrace/tracer/civisibility_tslv.go|323 col 61| undefined: constants.TestSessionIDTagName
ddtrace/tracer/civisibility_tslv.go|323 col 61| too many errors (typecheck)
ddtrace/tracer/civisibility_transport.go|72 col 49| undefined: constants.CiVisibilityAgentlessEnabledEnvironmentVariable
ddtrace/tracer/civisibility_transport.go|87 col 31| undefined: constants.CiVisibilityAgentlessURLEnvironmentVariable
ddtrace/tracer/civisibility_tslv.go|276 col 61| undefined: constants.TestSessionIDTagName
ddtrace/tracer/civisibility_tslv.go|277 col 60| undefined: constants.TestModuleIDTagName
ddtrace/tracer/civisibility_tslv.go|278 col 59| undefined: constants.TestSuiteIDTagName
ddtrace/tracer/civisibility_tslv.go|279 col 57| undefined: constants.ItrCorrelationIDTagName
ddtrace/tracer/civisibility_tslv.go|301 col 61| undefined: constants.TestSessionIDTagName
ddtrace/tracer/civisibility_tslv.go|302 col 60| undefined: constants.TestModuleIDTagName
ddtrace/tracer/civisibility_tslv.go|303 col 59| undefined: constants.TestSuiteIDTagName
ddtrace/tracer/civisibility_tslv.go|323 col 61| undefined: constants.TestSessionIDTagName
ddtrace/tracer/civisibility_tslv.go|323 col 61| too many errors) (typecheck)
ddtrace/tracer/civisibility_transport.go|72 col 49| undefined: constants.CiVisibilityAgentlessEnabledEnvironmentVariable
ddtrace/tracer/civisibility_transport.go|87 col 31| undefined: constants.CiVisibilityAgentlessURLEnvironmentVariable
ddtrace/tracer/civisibility_tslv.go|276 col 61| undefined: constants.TestSessionIDTagName
ddtrace/tracer/civisibility_tslv.go|277 col 60| undefined: constants.TestModuleIDTagName
ddtrace/tracer/civisibility_tslv.go|278 col 59| undefined: constants.TestSuiteIDTagName
ddtrace/tracer/civisibility_tslv.go|279 col 57| undefined: constants.ItrCorrelationIDTagName
ddtrace/tracer/civisibility_tslv.go|301 col 61| undefined: constants.TestSessionIDTagName
ddtrace/tracer/civisibility_tslv.go|302 col 60| undefined: constants.TestModuleIDTagName
ddtrace/tracer/civisibility_tslv.go|303 col 59| undefined: constants.TestSuiteIDTagName
ddtrace/tracer/civisibility_tslv.go|323 col 61| undefined: constants.TestSessionIDTagName
ddtrace/tracer/civisibility_tslv.go|323 col 61| too many errors) (typecheck)
ddtrace/tracer/civisibility_tslv.go
Outdated
func createTestEventFromSpan(span *span) *ciVisibilityEvent { | ||
tSpan := createTslvSpan(span) | ||
tSpan.SessionID = getAndRemoveMetaToUInt64(span, constants.TestSessionIDTagName) | ||
tSpan.ModuleID = getAndRemoveMetaToUInt64(span, constants.TestModuleIDTagName) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚫 [golangci] reported by reviewdog 🐶
undefined: constants.TestModuleIDTagName
ddtrace/tracer/civisibility_tslv.go
Outdated
tSpan := createTslvSpan(span) | ||
tSpan.SessionID = getAndRemoveMetaToUInt64(span, constants.TestSessionIDTagName) | ||
tSpan.ModuleID = getAndRemoveMetaToUInt64(span, constants.TestModuleIDTagName) | ||
tSpan.SuiteID = getAndRemoveMetaToUInt64(span, constants.TestSuiteIDTagName) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚫 [golangci] reported by reviewdog 🐶
undefined: constants.TestSuiteIDTagName
ddtrace/tracer/civisibility_tslv.go
Outdated
tSpan.SessionID = getAndRemoveMetaToUInt64(span, constants.TestSessionIDTagName) | ||
tSpan.ModuleID = getAndRemoveMetaToUInt64(span, constants.TestModuleIDTagName) | ||
tSpan.SuiteID = getAndRemoveMetaToUInt64(span, constants.TestSuiteIDTagName) | ||
tSpan.CorrelationID = getAndRemoveMeta(span, constants.ItrCorrelationIDTagName) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚫 [golangci] reported by reviewdog 🐶
undefined: constants.ItrCorrelationIDTagName
ddtrace/tracer/civisibility_tslv.go
Outdated
// A pointer to the created ciVisibilityEvent. | ||
func createTestSuiteEventFromSpan(span *span) *ciVisibilityEvent { | ||
tSpan := createTslvSpan(span) | ||
tSpan.SessionID = getAndRemoveMetaToUInt64(span, constants.TestSessionIDTagName) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚫 [golangci] reported by reviewdog 🐶
undefined: constants.TestSessionIDTagName
ddtrace/tracer/civisibility_tslv.go
Outdated
func createTestSuiteEventFromSpan(span *span) *ciVisibilityEvent { | ||
tSpan := createTslvSpan(span) | ||
tSpan.SessionID = getAndRemoveMetaToUInt64(span, constants.TestSessionIDTagName) | ||
tSpan.ModuleID = getAndRemoveMetaToUInt64(span, constants.TestModuleIDTagName) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚫 [golangci] reported by reviewdog 🐶
undefined: constants.TestModuleIDTagName
…isibility-part2-ddtrace-modifications
Co-authored-by: liashenko <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remaining comments which cannot be posted as a review comment to avoid GitHub Rate Limit
golangci
internal/civisibility/integrations/gotesting/testing_test.go|297 col 40| undefined: constants.TestModuleIDTagName (typecheck)
internal/civisibility/integrations/gotesting/testing_test.go|298 col 40| undefined: constants.TestSuiteIDTagName (typecheck)
func internalCiVisibilityInitialization(tracerInitializer func([]tracer.StartOption)) { | ||
ciVisibilityInitializationOnce.Do(func() { | ||
// Since calling this method indicates we are in CI Visibility mode, set the environment variable. | ||
_ = os.Setenv(constants.CiVisibilityEnabledEnvironmentVariable, "1") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚫 [golangci] reported by reviewdog 🐶
undefined: constants.CiVisibilityEnabledEnvironmentVariable
_ = utils.GetCodeOwners() | ||
|
||
// Preload all CI, Git, and CodeOwners tags. | ||
ciTags := utils.GetCiTags() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚫 [golangci] reported by reviewdog 🐶
undefined: utils.GetCiTags
}...) | ||
|
||
// Apply CI tags | ||
for k, v := range utils.GetCiTags() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚫 [golangci] reported by reviewdog 🐶
undefined: utils.GetCiTags
|
||
span, ctx := tracer.StartSpanFromContext(context.Background(), operationName, testOpts...) | ||
if suite.module.session != nil { | ||
span.SetTag(constants.TestSessionIDTagName, fmt.Sprint(suite.module.session.sessionID)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚫 [golangci] reported by reviewdog 🐶
undefined: constants.TestSessionIDTagName
if suite.module.session != nil { | ||
span.SetTag(constants.TestSessionIDTagName, fmt.Sprint(suite.module.session.sessionID)) | ||
} | ||
span.SetTag(constants.TestModuleIDTagName, fmt.Sprint(suite.module.moduleID)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚫 [golangci] reported by reviewdog 🐶
undefined: constants.TestModuleIDTagName
span.SetTag(constants.TestSessionIDTagName, fmt.Sprint(suite.module.session.sessionID)) | ||
} | ||
span.SetTag(constants.TestModuleIDTagName, fmt.Sprint(suite.module.moduleID)) | ||
span.SetTag(constants.TestSuiteIDTagName, fmt.Sprint(suite.suiteID)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚫 [golangci] reported by reviewdog 🐶
undefined: constants.TestSuiteIDTagName
} | ||
|
||
file, line := fn.FileLine(fn.Entry()) | ||
file = utils.GetRelativePathFromCiTagsSourceRoot(file) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚫 [golangci] reported by reviewdog 🐶
undefined: utils.GetRelativePathFromCiTagsSourceRoot
|
||
codeOwners := utils.GetCodeOwners() | ||
if codeOwners != nil { | ||
match := codeOwners.Match("/" + file) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚫 [golangci] reported by reviewdog 🐶
assignment mismatch: 1 variable but codeOwners.Match returns 2 values
span, ctx := tracer.StartSpanFromContext(context.Background(), operationName, testOpts...) | ||
moduleID := span.Context().SpanID() | ||
if session != nil { | ||
span.SetTag(constants.TestSessionIDTagName, fmt.Sprint(session.sessionID)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚫 [golangci] reported by reviewdog 🐶
undefined: constants.TestSessionIDTagName
if session != nil { | ||
span.SetTag(constants.TestSessionIDTagName, fmt.Sprint(session.sessionID)) | ||
} | ||
span.SetTag(constants.TestModuleIDTagName, fmt.Sprint(moduleID)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚫 [golangci] reported by reviewdog 🐶
undefined: constants.TestModuleIDTagName
1aba968
into
tony/civisibility-part1-consts-and-utils
What does this PR do?
This PR is a continuation of #2736 and adds support for
CI Visibility mode
insideddtrace
.When the CI Visibility mode is enabled, the tracer is initialised with the CIVisibility Writer, Transport and the custom Payload format.
The PR tries to reduce the impact on the current tracer code, by only modifying the
options
file to check if the civisibility mode is enabled and change the configuration to the ci visibility defaults, including the new transport. It also changes thetracer
file to set the civisibility writer when the civisibility mode is enabled.Motivation
The CI Visibility agentless intake has a custom payload format based on
events
.We want to reuse the current tracer implementation but making it compatible with the ci visibility format (aka
CI Visibility Protocol
) required to support Test Suite Level Visibility (tslv)More information about the protocol and TSLV can be found here and here
Stacked PRs
Reviewer's Checklist
Unsure? Have a question? Request a review!