Skip to content

Commit 8293fdf

Browse files
Small improvements to Table.Call traces (#125)
* Add table name to Table.Call trace attributes * Record error in trace if generate fails
1 parent 561a725 commit 8293fdf

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

plugin/table/table.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"github.com/osquery/osquery-go/gen/osquery"
1010
"github.com/osquery/osquery-go/traces"
1111
"github.com/pkg/errors"
12+
"go.opentelemetry.io/otel/codes"
1213
)
1314

1415
// Generate returns the rows generated by the table. The ctx argument
@@ -53,7 +54,7 @@ func (t *Plugin) Routes() osquery.ExtensionPluginResponse {
5354
}
5455

5556
func (t *Plugin) Call(ctx context.Context, request osquery.ExtensionPluginRequest) osquery.ExtensionResponse {
56-
ctx, span := traces.StartSpan(ctx, "Table.Call", "action", request["action"])
57+
ctx, span := traces.StartSpan(ctx, "Table.Call", "action", request["action"], "table_name", t.name)
5758
defer span.End()
5859

5960
ok := osquery.ExtensionStatus{Code: 0, Message: "OK"}
@@ -71,6 +72,8 @@ func (t *Plugin) Call(ctx context.Context, request osquery.ExtensionPluginReques
7172

7273
rows, err := t.generate(ctx, *queryContext)
7374
if err != nil {
75+
span.RecordError(err)
76+
span.SetStatus(codes.Error, err.Error())
7477
return osquery.ExtensionResponse{
7578
Status: &osquery.ExtensionStatus{
7679
Code: 1,

0 commit comments

Comments
 (0)