-
Notifications
You must be signed in to change notification settings - Fork 198
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
add span destination #1123
add span destination #1123
Conversation
💚 CLA has been signed |
@ivybridge-3c33 thanks for the PR! A few initial comments:
Regarding that last point, I think the more natural way to get the destination set would be to change the |
This reverts commit 88d440c.
thank you @axw |
@ivybridge-3c33 maybe you already saw, but v1.14.0 was just released which includes this change: https://github.com/elastic/apm-agent-go/releases/tag/v1.14.0 If you set |
I'll try at latest version first, |
@axw ExitSpan still not show up on the service map |
@ivybridge-3c33 I tested starting the span with diff --git a/module/apmgoredisv8/hook.go b/module/apmgoredisv8/hook.go
index d524c7b..907c061 100644
--- a/module/apmgoredisv8/hook.go
+++ b/module/apmgoredisv8/hook.go
@@ -40,7 +40,9 @@ func NewHook() redis.Hook {
// BeforeProcess initiates the span for the redis cmd
func (r *hook) BeforeProcess(ctx context.Context, cmd redis.Cmder) (context.Context, error) {
- _, ctx = apm.StartSpan(ctx, getCmdName(cmd), "db.redis")
+ _, ctx = apm.StartSpanOptions(ctx, getCmdName(cmd), "db.redis", apm.SpanOptions{
+ ExitSpan: true,
+ })
return ctx, nil
}
@@ -63,7 +65,9 @@ func (r *hook) BeforeProcessPipeline(ctx context.Context, cmds []redis.Cmder) (c
cmdNameBuf.WriteString(getCmdName(cmd))
}
- _, ctx = apm.StartSpan(ctx, cmdNameBuf.String(), "db.redis")
+ _, ctx = apm.StartSpanOptions(ctx, cmdNameBuf.String(), "db.redis", apm.SpanOptions{
+ ExitSpan: true,
+ })
return ctx, nil
}
diff --git a/module/apmgoredisv8/hook_test.go b/module/apmgoredisv8/hook_test.go
index d76e0f3..60e836e 100644
--- a/module/apmgoredisv8/hook_test.go
+++ b/module/apmgoredisv8/hook_test.go
@@ -74,12 +74,15 @@ func TestHook(t *testing.T) {
assert.Equal(t, "PING", spans[0].Name)
assert.Equal(t, "db", spans[0].Type)
assert.Equal(t, "redis", spans[0].Subtype)
+ assert.Equal(t, "redis", spans[0].Context.Destination.Service.Resource)
assert.Equal(t, "GET", spans[1].Name)
assert.Equal(t, "db", spans[1].Type)
assert.Equal(t, "redis", spans[1].Subtype)
+ assert.Equal(t, "redis", spans[2].Context.Destination.Service.Resource)
assert.Equal(t, "(empty command)", spans[2].Name)
assert.Equal(t, "db", spans[2].Type)
assert.Equal(t, "redis", spans[2].Subtype)
+ assert.Equal(t, "redis", spans[2].Context.Destination.Service.Resource)
})
}
}
@@ -102,6 +105,7 @@ func TestHookPipeline(t *testing.T) {
assert.Equal(t, "GET, SET, GET, (empty command)", spans[0].Name)
assert.Equal(t, "db", spans[0].Type)
assert.Equal(t, "redis", spans[0].Subtype)
+ assert.Equal(t, "redis", spans[0].Context.Destination.Service.Resource)
})
}
}
@@ -132,6 +136,7 @@ func TestHookTxPipeline(t *testing.T) {
}
assert.Equal(t, "db", spans[0].Type)
assert.Equal(t, "redis", spans[0].Subtype)
+ assert.Equal(t, "redis", spans[0].Context.Destination.Service.Resource)
})
}
} Updating your PR to only use the |
thank you very much it's work, now my pr updated please review |
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, thanks @ivybridge-3c33 !
/test |
Add span destination for redisv8 hook to support elastic apm services map.